Skip to content

DOC: Change doc template to fix SA04 errors in docstrings #28792 #32972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 10, 2020

Conversation

dilex42
Copy link
Contributor

@dilex42 dilex42 commented Mar 24, 2020

As requested in #32823 creating separate PR.
Also all descriptions for methods starts with upper case and it looks a little out of place. Should it be casted to lowercase perhaps?

@jreback jreback added the Docs label Mar 29, 2020
@jreback
Copy link
Contributor

jreback commented Mar 29, 2020

cc @datapythonista

@jreback jreback added this to the 1.1 milestone Mar 29, 2020
@datapythonista
Copy link
Member

Thanks @dilex42.

My preference would be, instead of just listing the reverse of each method (add <-> radd...), adding all the related methods in all docstrings:

See Also
--------
Series.add : ...
Series.radd : ...
Series.mul : ...
...

It'll be a bit long, but I don't think too much. I think all them are relevant for the users. And it'll reduce the complexity of that function, instead of increasing it.

I guess it makes sense to have two, one for comparisons, and one for algebra operations.

What do you think?

@dilex42
Copy link
Contributor Author

dilex42 commented Mar 29, 2020

I don't have experience to comment from designing perspective to what approach better.

I guess having all functions listed is reasonable. But if I understand correctly there will be 2 static templates, additional type param for each method and then some templates concatenation based on type so I don't know if it's gonna be less complex.

@datapythonista
Copy link
Member

Can't really tell without spending a decent amount of time where those docstrings are being used. I think for dataframe docstrings there are different templates, I thought it was the same for series. In that case my preferred option would be to have arithmetic and comparison methods all together in the See Also.

@WillAyd do you have an opinion here?

See Also
--------
Series.{reverse}
Series.{reverse} : {see_also_desc}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, can you undo the rest of the changes, and just leave something generic like this?

Suggested change
Series.{reverse} : {see_also_desc}.
Series.{reverse} : Reverse of the operator, see `Python documentation <https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types>__` for more details.

This fixes the docstring validation problem, adds useful information to the user, and keeps things simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will still be a problem with comparision operators rendering Series.None. I really can't see a way to handle both algebraic and comparision operators with one template.

@dilex42
Copy link
Contributor Author

dilex42 commented Apr 1, 2020

The way I see it, we need to answer can we make it work with single flex template? If yes then sure let's do that. But if not then let's find the best solution with two templates.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't understand that the docstring of Series.eq was broken, and rendering Series.None in the see also.

Let's move forward then with this. Added couple of comments, but looks good.

doc_see_also = _see_also_reverse_SERIES.format(
reverse=op_desc["reverse"], see_also_desc=op_desc["see_also_desc"],
)
doc_no_examples = doc_no_examples + doc_see_also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the examples part of the doc building is already to complex to mix the see also in here.

Can you move this condition after line 13, and have something like:

if op_desc["reverse"]:
    base_doc += _see_also_reverse_SERIES.format(...)

I think this will be clearer this way.

@@ -352,6 +356,12 @@ def _make_flex_doc(op_name, typ):
if reverse_op is not None:
_op_descriptions[reverse_op] = _op_descriptions[key].copy()
_op_descriptions[reverse_op]["reverse"] = key
_op_descriptions[key][
"see_also_desc"
] = f"Reversed {_op_descriptions[key]['desc']}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind writing a more descriptive description? I don't think for a user being shown radd for the first time, telling them Reverse add is very helpful. I wrote an example with a link in a previous comment that you can use as reference.

] = f"Reversed {_op_descriptions[key]['desc']}"
_op_descriptions[reverse_op][
"see_also_desc"
] = f"Usual {_op_descriptions[key]['desc']}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this description can also be improved.

@dilex42
Copy link
Contributor Author

dilex42 commented Apr 2, 2020

Is this description and formatting good?

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @dilex42 for the work on this.

@WillAyd
Copy link
Member

WillAyd commented Apr 7, 2020

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@WillAyd WillAyd merged commit 12ffb23 into pandas-dev:master Apr 10, 2020
@WillAyd
Copy link
Member

WillAyd commented Apr 10, 2020

Thanks @dilex42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants